package org.room402.constant.system;

import lombok.AllArgsConstructor;
import org.room402.entity.system.BusinessError;

@AllArgsConstructor
public enum ErrorCode {
    CHAT_POOL_NOT_FOUND("0001", "聊天池不存在", ErrorLevel.BUG),
    USER_NOT_FOUND("0002", "用户不存在", ErrorLevel.BUG),
    ;
    private String code;
    private String msg;
    private ErrorLevel level;

    public void throwException() {
        throw getException();
    }

    public BusinessError getException() {
        return new BusinessError(this.code, this.msg, this.level);
    }

    public enum ErrorLevel {
        /**
         * 非异常
         */
        NONE,
        /**
         * 警告
         */
        WARING,
        /**
         * 错误
         */
        ERROR,
        /**
         * 漏洞
         */
        BUG;
    }
}
